//
//  ForgetPasswordVC.m
//  genericframework
//
//  Created by 谷丰 on 2025/4/2.
//

#import "ForgetPasswordVC.h"
<<<<<<< HEAD
#import "ReplacePasswordVC.h"
@interface ForgetPasswordVC ()<UITextFieldDelegate>
@property (nonatomic,strong)UIImageView * BgImageView;//登录背景
@property (nonatomic,strong)UIImageView * LogoImageView;//Logo
@property (nonatomic, strong) UITextField *accountTextField;   // 账号
@property (nonatomic, strong) UIButton *loginButton;   // 确定按钮
@end

@implementation ForgetPasswordVC
// 登录按钮（透明背景 + 白色边框 + 圆角）
- (UIButton *)loginButton {
    if (!_loginButton) {
        _loginButton = [UIButton buttonWithType:UIButtonTypeCustom];
        [_loginButton setTitle:GFString(@"确定") forState:UIControlStateNormal];
        _loginButton.titleLabel.font = GFFont(14);
        [_loginButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
        _loginButton.backgroundColor = [BaseWay MainColor];
        // 设置圆角和边框
        _loginButton.layer.cornerRadius = FitSizeW(20);  // 高度30，圆角15
        _loginButton.layer.borderWidth = 1.0;
        _loginButton.layer.borderColor = [BaseWay MainColor].CGColor;
        // 添加点击事件
        [_loginButton addTarget:self action:@selector(UpdateClick) forControlEvents:UIControlEventTouchUpInside];
        [self.view addSubview:_loginButton];
    }
    return _loginButton;
}

-(UIImageView *)BgImageView{
    if (!_BgImageView) {
        _BgImageView = [[UIImageView alloc]init];
        _BgImageView.image = [UIImage imageNamed:@"背景"];
        _BgImageView.contentMode = UIViewContentModeScaleAspectFill;
        [self.view addSubview:_BgImageView];
    }
    return _BgImageView;
}
-(UIImageView *)LogoImageView{
    if (!_LogoImageView) {
        _LogoImageView = [[UIImageView alloc]init];
        _LogoImageView.image = [UIImage imageNamed:@"logo"];
        _LogoImageView.contentMode = UIViewContentModeScaleAspectFill;
        _LogoImageView.layer.cornerRadius=FitSizeW(11);
        _LogoImageView.clipsToBounds=YES;
        [self.view addSubview:_LogoImageView];
    }
    return _LogoImageView;
}
// 账号输入框（8-16位数字或字母）
- (UITextField *)accountTextField {
    if (!_accountTextField) {
        _accountTextField = [self createTextFieldWithPlaceholder:GFString(@"请输入账号")  leftImageName:@"icon-登录账号"];
        _accountTextField.keyboardType = UIKeyboardTypeASCIICapable;
        _accountTextField.clearsOnBeginEditing = YES;
        _accountTextField.clearButtonMode=  UITextFieldViewModeAlways;
        _accountTextField.delegate = self;
    }
    return _accountTextField;
}
- (void)viewDidLoad {
    [super viewDidLoad];
    self.BgImageView.frame= CGRectMake(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT);
    [self CompositionNavBarHidden:NO andHiddenBackButton:NO withTitle:GFString(@"忘记密码")];
    [self.BaseBackButton setImage:[UIImage imageNamed:@"icon_返回 拷贝 2"] forState:0];
    self.BaseNavBarView.backgroundColor=[UIColor clearColor];
    // 添加所有 TextField
    [self.view addSubview:self.accountTextField];
    self.accountTextField.frame=CGRectMake(FitSizeW(35),NAVIGATION_BAR_HEIGHT+FitSizeW(40), SCREEN_WIDTH-FitSizeW(70), FitSizeW(50));
//    if (self.AccountText) {
//        self.accountTextField.text = self.AccountText;
//    }
    self.loginButton.frame=CGRectMake(FitSizeW(35), CGRectGetMaxY(self.accountTextField.frame)+FitSizeW(40), SCREEN_WIDTH-FitSizeW(70), FitSizeW(40));
    // Do any additional setup after loading the view.
}
#pragma mark - 创建通用 TextField（带 leftView 和底部白线）
- (UITextField *)createTextFieldWithPlaceholder:(NSString *)placeholder leftImageName:(NSString *)imageName {
    UITextField *textField = [[UITextField alloc] init];
    textField.placeholder = placeholder;
    textField.font = GFFont(14);
    textField.textColor = [UIColor whiteColor];
    
    textField.attributedPlaceholder = [[NSAttributedString alloc] initWithString:placeholder attributes:@{NSForegroundColorAttributeName: rgba(255, 255, 255, 1),NSFontAttributeName: GFFont(14)}];
    UIView * leftView = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 25, FitSizeW(50))];
    leftView.backgroundColor=[UIColor clearColor];
    // 设置左侧图标（20×20）
    UIImageView *leftImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imageName]];
    leftImageView.frame = CGRectMake(0, FitSizeW(17.5), FitSizeW(15), FitSizeW(15));
    leftImageView.contentMode = UIViewContentModeScaleAspectFit;
    [leftView addSubview:leftImageView];
    textField.leftView = leftView;
    textField.leftViewMode = UITextFieldViewModeAlways;
    
    // 底部白色线条
    UIView *bottomLine = [[UIView alloc] init];
    bottomLine.backgroundColor = [UIColor whiteColor];
    [textField addSubview:bottomLine];
    
    // 使用 Auto Layout 布局底部线条
    bottomLine.translatesAutoresizingMaskIntoConstraints = NO;
    [NSLayoutConstraint activateConstraints:@[
        [bottomLine.leadingAnchor constraintEqualToAnchor:textField.leadingAnchor],
        [bottomLine.trailingAnchor constraintEqualToAnchor:textField.trailingAnchor],
        [bottomLine.bottomAnchor constraintEqualToAnchor:textField.bottomAnchor],
        [bottomLine.heightAnchor constraintEqualToConstant:1]
    ]];
    
    return textField;
}
#pragma mark - UITextFieldDelegate（限制账号输入 8-16 位数字或字母）
- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string {
    if (textField == self.accountTextField) {
        // 只允许输入字母和数字
        NSCharacterSet *allowedChars = [NSCharacterSet alphanumericCharacterSet];
        NSCharacterSet *inputChars = [NSCharacterSet characterSetWithCharactersInString:string];
        if (![allowedChars isSupersetOfSet:inputChars]) {
            return NO;
        }
        
        // 限制长度 8-16 位
        NSString *newText = [textField.text stringByReplacingCharactersInRange:range withString:string];
        return newText.length <= 16;
    }
    return YES;
}
-(void)UpdateClick{
    
    if(self.accountTextField.text.length<1||self.accountTextField.text.length>16){
        [self ShowTextString:GFString(@"请输入正确账号") andWithTime:1 dissmess:^(id  _Nonnull responseObject) {
                    
        }];
    }else{
        
        
        
        
        ReplacePasswordVC * replace = [[ReplacePasswordVC alloc]init];
        replace.AccountText = self.accountTextField.text;
        replace.hidesBottomBarWhenPushed=YES;
        [self.navigationController pushViewController:replace animated:YES];
    }
}
=======

@interface ForgetPasswordVC ()

@end

@implementation ForgetPasswordVC

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
}

>>>>>>> 291cab90cbb8ff4921e32ec95b13330bf79c214c
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
